﻿@{
    ViewBag.Title = "试题管理";
}
@using PagedList
@using PagedList.Mvc
@model PagedList.IPagedList<zqdn.Web.ViewModels.ExViewModel>

<div class="pageheader">
    <h2><i class="fa fa-user"></i> 试题列表 </h2>
</div>

<div class="contentpanel">
    <div class="row">
        <a href="/admin/Ex/Create" class="btn btn-primary">添加试题</a>
    </div>
    <div class="row">
        <div class="table-responsive">
            <table class="table table-hidaction table-hover">
                <thead>
                    <tr>
                        <th width="60%">题目</th>
                        <th>选项</th>
                        <th>正确答案</th>
                        <th width="6%">操作</th>
                    </tr>
                </thead>
                <tbody>
                  @foreach (var item in Model)
                    {
                        <tr>
                            <td>@item.Title</td>
                            <td class="optionCol" data-options="@item.Option"></td>
                            <td>@item.TureOption</td>
                            <td>
                                <a href="/admin/ex/edit?id=@item.ID">编辑</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div><!-- table-responsive -->
        @Html.PagedListPager((PagedList.IPagedList)Model, page => Url.Action("Index", new
                           {
                               page,
                               adName = ViewBag.AdName
                           })
                            , PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
                            new PagedListRenderOptions()
                            {
                                LinkToPreviousPageFormat = "上一页",
                                LinkToNextPageFormat = "下一页",
                                MaximumPageNumbersToDisplay = 5
                            }, new AjaxOptions()
                            {
                                HttpMethod = "GET"
                            }))
    </div><!-- row -->
</div>
<script>
    $(function () {
        $(".optionCol").each(function () {
            var data = $(this).attr("data-options");
            var obj = $.parseJSON(data);
            var html = "";
            $.each(obj, function (i, val) {
                var p = "<p>" + i + ":" + val + "</p>"
                html += p;
            });
            $(this).html(html)
        });
    });
</script>
 